from urllib.request import *
from fake_useragent import *

# 请求头的设置

url = 'https://www.baidu.com'

# 获取fake_useragent库中的UserAgent
agent = UserAgent()

headers = {
    "User-agent": agent.chrome
}

request = Request(url, headers=headers)

print(request.get_header("User-agent"))

response = urlopen(request)

info = response.read()

print(info.recode())
